/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.services;

import java.util.LinkedList;
import java.util.List;
import tpdisenio2009.model.beans.SoccerMatch;
import tpdisenio2009.model.beans.TournamentDate;
import tpdisenio2009.model.dao.FantasyTeamDAO;
import tpdisenio2009.model.dao.FantasyTeamScoreByTournamentDateDAO;
import tpdisenio2009.model.dao.SoccerMatchDAO;
import tpdisenio2009.model.dao.SoccerPlayerDAO;

/**
 *
 * @author DeuterioX
 */
public class SoccerMatchService {

    private final SoccerMatchDAO soccerMatchDAO;

    private final FantasyTeamDAO fantasyTeamDAO;

    private final SoccerPlayerDAO soccerPlayerDAO;

    private final FantasyTeamScoreByTournamentDateDAO fantasyTeamScoreByTournamentDateDAO;

    public SoccerMatchService() {
        soccerMatchDAO = new SoccerMatchDAO();
        fantasyTeamDAO = new FantasyTeamDAO();
        soccerPlayerDAO = new SoccerPlayerDAO();
        fantasyTeamScoreByTournamentDateDAO = new FantasyTeamScoreByTournamentDateDAO();
    }

    public List<SoccerMatch> getAll() {
        return soccerMatchDAO.getAll();
    }

    public LinkedList<String> getMatchState() {
        LinkedList<String> states = new LinkedList<String>();
        states.add( SoccerMatch.SUSPENDED_MATCH );
        states.add( SoccerMatch.POSTPONED_MATCH );
        states.add( SoccerMatch.PLAYED_MATCH );
        return states;
    }

    public void updateSoccerMatchState( Integer id, String state ) {
        SoccerMatch match = soccerMatchDAO.getById( id );
        match.setState( state );
        updateSoccerMatch( match );
    }

    private void updateSoccerMatch( SoccerMatch match ) {
        soccerMatchDAO.update( match );
    }

    public List<SoccerMatch> getSoccerMatchByTournamentDate( TournamentDate date ) {
        return soccerMatchDAO.getSoccerMatchByTournamentDate( date );
    }
}
